package com.example.objectstream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectStreamDemo2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        /**
         * 反序列流/对象操作输入流
         * 将本地文件中的对象读入到程序中
         */

        //1.创建反序列流对象
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("src/com/example/file/student.txt"));

        //2.读取数据
        Student o = (Student) ois.readObject();

        //3.打印对象
        System.out.println(o);

        //释放资源
        ois.close();

    }
}
